1. Field of the Invention
The present invention relates to techniques to associate execution characteristics of program code with particular instructions or operations thereof and, in particular, to techniques that facilitate preparation and/or optimization of program code based at least in part on execution characteristics collected and associated with particular instructions or operations thereof.
2. Description of the Related Art
Code profiling techniques have long been used to gain insight into execution performance of computer programs. Often, such insights are valuable and allow programmers to improve the execution performance of their computer programs. Indeed, a large body of work exists in the field of profiling. In general, two major classes of techniques exist: code instrumentation and hardware assisted profiling. Code instrumentation techniques typically include the insertion of instructions into the instruction stream of a program to be profiled. In crude form, programmer insertion of print source statements may be employed to profile code. More sophisticated approaches may employ compiler facilities or options to insert appropriate instructions or operations to support profiling. Upon execution of the instrumented code, execution characteristics are sampled, in part by operation of the added instructions. Typically, code instrumentation techniques impose overhead on original program code so instrumented and, unfortunately, the insertion of instructions into the instruction stream may itself alter the behavior of the program code being sampled.
Hardware assisted profiling techniques have been developed, in part, to address such limitations by off loading some aspects to dedicated hardware such as event counters. Practical implementations often employ aspects of code instrumentation and hardware assistance. In some cases, profiling support is included in, or patched into, exception handler code to avoid imposing overhead on each execution of a sampled instruction. Suitable hardware event counters are provided in advanced processor implementations such as those in accordance with the SPARC® and Alpha processor architectures. SPARC architecture based processors are available from Sun Microsystems, Inc, Palo Alto, Calif. SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the United States and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems. Systems that include Alpha processors are available from a number of sources including Compaq Computer Corporation.
One reasonably comprehensive hardware assisted profiling environment is provided by the Digital Continuous Profiling Infrastructure (DCPI) tools that run on Alpha processor systems to provide profile information at several levels of granularity, from whole images down to individual procedures and basic blocks on down to detailed information about individual instructions, including information about dynamic behavior such as cache misses, branch mispredicts and other forms of dynamic stalls. Detailed information on the DCPI tools and downloadable code may be found (at least as of the filing date) online. Additional descriptive information appears in Jennifer Anderson, Lance Berc, George Chrysos, Jeffrey Dean, Sanjay Ghemawat, Jamey Hicks, Shun-Tak Leung, Mitch Lichtenberg, Mark Vandevoorde, Carl A. Waldspurger, William E. Weihl, “Transparent, Low-Overhead Profiling on Modem Processors,” in Proceedings of the Workshop on Profile and Feedback-Directed Compilation in conjunction with the International Conference on Parallel Architectures and Compilation Techniques (PACT 98), Paris, France (Oct. 13, 1998).
One longstanding goal of compiler writers has been to utilize profiling results in subsequent preparation and/or optimizations of profiled program code. Unfortunately, utilization of profile information can be difficult, particularly at the instruction-level desirable for optimizations related to processor or pipeline stall conditions. One significant challenge is the preparation of an executable for use in a measurement or collection phase, where execution behavior of the collection phase executable is itself representative or predictive of execution behavior of production code. Another challenge is establishing correspondence between profiled execution behavior and instructions, operations or sequences of instructions or operations that can be optimized.